I'm brand new to Verilog and hardware design all together. I've recently purchased the Nexy2 (Spartan3e) Board. I'm having trouble on how to approach the code portion of writing decoder and encoder modules as well as the module that will instantiate them together. I'm attempting to get this code to display on my board through the board as well.
Right now the only thing I have completed is (and I'm going to assume it's wrong) :
Yeah, three switches will count as the inputs and the LED's will be the eight outputs. So I've done some more (renamed variables in decoder as well).
So far I have :
if these two are correct, my new problem is creating the top module that will instantiate the encoder and decoder modules that will interconnect them with the addition of inverters on the outputs.
module DecEnc_tb;reg[2:0] in;wire[2:0] out;integer i;//instantiate the DUT
DecEnc DecEnc(.in(in), .out(out));//create the stimulusinitialbegin
in =0;
i =0;for(i=0; i<B; i=i+i)#100 in = i[2:0];endendmodule
You shouldn't have too much trouble with that test bench, since it's pretty simple, except for these things:
You previously named the ports dIN and dOUT, and this test bench is expecting them to be called in and out
Your module was called decoder and the test bench is expecting DecEnc
The value of B is not defined
Your decoder expects a 3-bit input and emits an 8-bit output, which doesn't match what the test bench declares, but that could be because the test bench is testing an encoder connected to a decoder (which should theoretically emit the input value, if the operation is symmetric)