yosys/tests/asicworld/code_verilog_tutorial_v2k_r...

25 lines
520 B
Coq
Raw Normal View History

2013-01-05 04:13:26 -06:00
module v2k_reg();
// v2k allows to init variables
reg a = 0;
// Here only last variable is set to 0, i.e d = 0
// Rest b, c are set to x
reg b, c, d = 0;
// reg data type can be signed in v2k
// We can assign with signed constants
reg signed [7:0] data = 8'shF0;
// Function can return signed values
// Its ports can contain signed ports
function signed [7:0] adder;
input a_in;
input b_in;
input c_in;
input signed [7:0] data_in;
begin
adder = a_in + b_in + c_in + data_in;
end
endfunction
endmodule