View Full Version : woo! i can write a 3bit address 4bit data memory in verilog

10-15-2005, 02:40 PM
module mem (address, datain, dataout, clk, WE, RE);

input [2:0] address;
input [3:0] datain;
input clk, WE, RE;

output [3:0] dataout;
reg [3:0] dataout;

reg [3:0] mem_data [7 : 0];

integer i;
for (i=0; i<8; i=i+1)
mem_data[i] = 4'b0;

always @(posedge clk)
if (WE & !RE)
mem_data[address] <= datain;
else if (!WE & RE)
dataout <= mem_data[address];
dataout <= 4'b0;



results of the testbench: www.csulb.edu/~rjames/test.ps

10-15-2005, 02:46 PM
Verilog? mmh I'm learning VHDL this year; our teacher told us that Verilog is very similar to VHDL. Perhaps in 2 or 3 months I can understand this code :p

10-15-2005, 02:51 PM
vhdl is similar to ada, verilog is similar to c.

verilog is the more commonly used hdl in america (90/10 verilog) whereas vhdl is the common one in europe (90/10 vhdl)

10-15-2005, 02:58 PM
I see. That's why I'm learning VHDL then... Actually, I meant that both languages were used for the same purpose.

We've seen some VHDL code and it isn't similar to that code you posted, indeed. Verilog seems to be more... intuitive? It seems easier to write than VHDL, too.

10-15-2005, 03:02 PM
from what i can tell they're both powerful languages, and they do serve the same purpose (in the same way that C++ and Pascal serve the same purpose). i perfer verilog because it resembles languages i'm already familar with (i've never programmed in ada before) plus it's open source, plus i've worked with cadence over the past few years, and they're the "guiding hand" in verilog development.

10-15-2005, 03:08 PM
I'm starting to hate my univeristy for teaching us VHDL... LOL

I've never learnt ADA before, so yeah, it's harder to learn this new language. Maybe it would have been a better idea to teach us Verilog, as it's similar to C and C is similar to Java. And we work a lot with Java. But meh...

10-15-2005, 03:09 PM
if you're going to work in the hardware industry in europe, it seems that you'd need to know vhdl. the only big company using vhdl in america is intel.

10-15-2005, 03:12 PM
I have no idea what you are talking about.

"There are 10 types of people in the world, those that understand binary and those who don't"

^I saw that on a t-shirt

10-15-2005, 03:13 PM
hahahahahha yeah, I've seen this, too :p

EDIT: Well, I didn't know what 'Twizzlers' were =P

10-15-2005, 03:15 PM
i have that shirt... in fact, and i hate you for this, i'm wearing it right now.

10-15-2005, 03:16 PM
i have that shirt... in fact, and i hate you for this, i'm wearing it right now.

You hate me? Why?

10-15-2005, 03:17 PM
because you said that shirt and i was thinking "haha, i have that shirt--wait a second... *looks down slowly*"

do you have a camera in my apartment or something?

10-15-2005, 03:20 PM
lol. No. One of my friends has that shirt. But I knew you were wearing it because I AM PSYCHIC!!!!!! Wow, that was retarded.

10-15-2005, 03:20 PM
Did you get it off thinkgeek.com? I want to try the caffeinated soap.

10-15-2005, 03:21 PM
Wow, that must have been a really weird situation Endymion.... haha!

Although I think those kind of shirts are funny, I would never buy or wear any... they're too freak for me.

10-15-2005, 04:08 PM
mine's from thinkgeek.

10-15-2005, 05:35 PM
what the fuck?