FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > Verilog

Verilog comp.lang.verilog newsgroup / usenet

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-18-2006, 07:13 AM
deadsy
Guest
 
Posts: n/a
Default Dual Port RAM: Different Bus Sizes?

Hi:

I'm trying to define a dual port ram device with a 16kx16bit bus and a
32Kx8bit bus referring to the same memory.
The following gets the job done- but it uses a mux to select 8 of 16 for the
8 bit data bus.
I'm using a Xilinx part and I understand the ram blocks can be setup with
different bus aspect ratios.
Is there a way to convince the synthesiser to do this in plain old verilog,
without resorting to direct instantiation of the Xilinx ram block primitive?

I'm a newbie to verilog- so I hope this isn't a dumb question.

Thanks,
Jason H.

module system_ram
(
input clk,
input we,
input [13:0] adr,
input [15:0] di,
output reg [15:0] do,
input vclk,
input [14:0] vadr,
output [7:0] vdata
);

// 16384 x 16 bits = 32K

reg [15:0] mem[0:16383];

always @( posedge clk ) begin
if ( we != 0 )
mem[adr] <= di;
else
do <= mem[adr];
end

reg [15:0] q;

always @( posedge vclk ) begin
q <= mem[vadr>>1];
end

assign vdata = (vadr&1) ? q[7:0] : q[15:8];

endmodule


Reply With Quote
  #2 (permalink)  
Old 05-18-2006, 08:41 PM
gabor
Guest
 
Posts: n/a
Default Re: Dual Port RAM: Different Bus Sizes?

Hi Jason,

I think a synthesizer would need to be pretty smart to infer
a block ram with different port sizes. Also note that the code
you have below does not describe this. In the block ram
without an output mux, the data on the output would depend
on the address of the previous clock cycle. Your mux
is combinatorial and uses the LSB of the address on this clock
cycle. If a synthesis tool could infer a block RAM with two
different port sizes, you'd need to fix this.

Good Luck,
Gabor

deadsy wrote:
> Hi:
>
> I'm trying to define a dual port ram device with a 16kx16bit bus and a
> 32Kx8bit bus referring to the same memory.
> The following gets the job done- but it uses a mux to select 8 of 16 for the
> 8 bit data bus.
> I'm using a Xilinx part and I understand the ram blocks can be setup with
> different bus aspect ratios.
> Is there a way to convince the synthesiser to do this in plain old verilog,
> without resorting to direct instantiation of the Xilinx ram block primitive?
>
> I'm a newbie to verilog- so I hope this isn't a dumb question.
>
> Thanks,
> Jason H.
>
> module system_ram
> (
> input clk,
> input we,
> input [13:0] adr,
> input [15:0] di,
> output reg [15:0] do,
> input vclk,
> input [14:0] vadr,
> output [7:0] vdata
> );
>
> // 16384 x 16 bits = 32K
>
> reg [15:0] mem[0:16383];
>
> always @( posedge clk ) begin
> if ( we != 0 )
> mem[adr] <= di;
> else
> do <= mem[adr];
> end
>
> reg [15:0] q;
>
> always @( posedge vclk ) begin
> q <= mem[vadr>>1];
> end
>
> assign vdata = (vadr&1) ? q[7:0] : q[15:8];
>
> endmodule


Reply With Quote
  #3 (permalink)  
Old 05-19-2006, 04:58 AM
deadsy
Guest
 
Posts: n/a
Default Re: Dual Port RAM: Different Bus Sizes?

>Also note that the code you have below does not describe this

Hmm. Yes- thanks for catching that. Easily solved by running the vadr[0]
through a D flip flop.
Unfortunately this still doesn't convince the synth to simplify the design
to a ram block with different bus sizes.
At this stage I'd rather the code stay succinct and portable, so I guess
I'll live with it.

Thanks,
Jason H.


"gabor" <[email protected]> wrote in message
news:[email protected] oups.com...
> Hi Jason,
>
> I think a synthesizer would need to be pretty smart to infer
> a block ram with different port sizes. Also note that the code
> you have below does not describe this. In the block ram
> without an output mux, the data on the output would depend
> on the address of the previous clock cycle. Your mux
> is combinatorial and uses the LSB of the address on this clock
> cycle. If a synthesis tool could infer a block RAM with two
> different port sizes, you'd need to fix this.
>
> Good Luck,
> Gabor
>
> deadsy wrote:
>> Hi:
>>
>> I'm trying to define a dual port ram device with a 16kx16bit bus and a
>> 32Kx8bit bus referring to the same memory.
>> The following gets the job done- but it uses a mux to select 8 of 16 for
>> the
>> 8 bit data bus.
>> I'm using a Xilinx part and I understand the ram blocks can be setup with
>> different bus aspect ratios.
>> Is there a way to convince the synthesiser to do this in plain old
>> verilog,
>> without resorting to direct instantiation of the Xilinx ram block
>> primitive?
>>
>> I'm a newbie to verilog- so I hope this isn't a dumb question.
>>
>> Thanks,
>> Jason H.
>>
>> module system_ram
>> (
>> input clk,
>> input we,
>> input [13:0] adr,
>> input [15:0] di,
>> output reg [15:0] do,
>> input vclk,
>> input [14:0] vadr,
>> output [7:0] vdata
>> );
>>
>> // 16384 x 16 bits = 32K
>>
>> reg [15:0] mem[0:16383];
>>
>> always @( posedge clk ) begin
>> if ( we != 0 )
>> mem[adr] <= di;
>> else
>> do <= mem[adr];
>> end
>>
>> reg [15:0] q;
>>
>> always @( posedge vclk ) begin
>> q <= mem[vadr>>1];
>> end
>>
>> assign vdata = (vadr&1) ? q[7:0] : q[15:8];
>>
>> endmodule

>



Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I make dual-port RAM from single port RAM? Frank @ CN Verilog 34 03-06-2006 12:33 PM
help:dual-edge flip-flop possible using Verilog? yyqonline Verilog 1 01-25-2006 02:01 PM
port sizes dont match ? dolly Verilog 1 10-29-2004 10:21 PM
infer dual-port Block RAM with different dimensions kyrten Verilog 0 08-25-2004 07:55 PM
Verilog operand sizes David Jones Verilog 1 09-19-2003 09:21 PM


All times are GMT +1. The time now is 02:50 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved