I am trying to create a 32-bit counter that breaks the 32 inputs into 4 groups of 8 then feeds those 4 groups into a mux. This is what I have:
modules Bit32 ( clk, reset, load, D, Q);
input clk, reset, load, D, Q;
input [7:0] D;
input [15:8] D;
input [23:16] D;
input [31:24] D;
output [7:0] Q;
output [15:8] Q;
output [23:16] Q;
output [31:24] Q;
reg [7:0] Q;
reg [15:8] Q;
reg [23:16] Q;
reg [31:24] Q;
always @(posedge clk)
if(reset) Q <=32'b0; else
if (load) Q <=D;
else Q <=Q + 32'b1
endmodule
I receive these errors:
ERROR:HDLCompiler:944 - "C:/Users/Skyla/Documents/csulb/Fall17/201/assign5/Bit32.v" Line 1: Unexpected module instantiations outside module boundaries.
WARNING:HDLCompiler:1591 - "C:/Users/Skyla/Documents/csulb/Fall17/201/assign5/Bit32.v" Line 1: Root scope declaration is not allowed in verilog 95/2K mode
ERROR:HDLCompiler:806 - "C:/Users/Skyla/Documents/csulb/Fall17/201/assign5/Bit32.v" Line 2: Syntax error near "input".
My mux:
module CounterMux(select, D, Q);
input[1:0] select;
input[3:0] D:
output Q;
wire Q;
wire [1:0] select;
wire [3:0] D;
assign Q=D[select];
endmodule
Bit32
you declaredD
andQ
5 times ( 1 as single bit, 4 as 8-bits). InCounterMux
there is an obvious typo. I suggest you learn and implent an ANSI header style. It is fewer lines of code, easier to read, and less error prone. The Non-ANSI style if for backward comparability support. - Greg