Friday 9 October 2015

clock - Counter in verilog


i want to make a counter that increases by the value of its inputs, but i did the testbench and the output is undetermined, xxxx. Can someone tell me if there is something wrong in this code?


    //Count

module count(clk,

rst, val, coin



);
//DeclaraciĆ³n entradas y salidas

input clk, rst;
input [3:0] coin;
output [3:0] val;

reg [3:0] val;
reg [3:0] nval;



always @(posedge clk, negedge rst)
if(rst == 0) val <= 4'b0000;
else val <= nval;

always @(val)
nval <= val + coin ;
endmodule


No comments:

Post a Comment

arduino - Can I use TI&#39;s cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...