Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)

Verilog HDL CODE Help!

Altera_Forum
Honored Contributor II
2,173 Views

Cancelled:cry::cry::cry::cool:

0 Kudos
11 Replies
Altera_Forum
Honored Contributor II
1,478 Views

These are basic exercises. 

Looks like an homework? :-) 

 

Spend at least ten minutes looking into an HDL book and we'll see
0 Kudos
Altera_Forum
Honored Contributor II
1,478 Views

Cancelled:cry::cry::cry::cool:

0 Kudos
Altera_Forum
Honored Contributor II
1,478 Views

Cancelled:cry::cry::cry::cool:

0 Kudos
Altera_Forum
Honored Contributor II
1,478 Views

The UD counter looks ok. 

 

The MUX uses a command I don't know. 

 

--- Quote Start ---  

assign mux_out = (sel)?SOURCE0_IH:SOURCE1_IH:SOURCE2_IH:SOURCE3_IH: SOURCE4_IH:SOURCE5_IH:SOURCE6_IH:SOURCE7_IH; 

 

--- Quote End ---  

I only use the conditional operator (?) as a ternary operator. Don't know if can be used in this sense. 

 

I would use a case statement: 

 

--- Quote Start ---  

reg mux_out; 

always @(sel,SOURCE0_IH,SOURCE1_IH, etc.) 

case (sel) 

3'b000: mux_out = SOURCE0_IH; 

3'b001: mux_out = SOURCE1_IH; 

... 

default: mux_out = 1'b0; 

endcase 

 

--- Quote End ---  

0 Kudos
Altera_Forum
Honored Contributor II
1,478 Views

Cancelled:cry::cry::cry::cool:

0 Kudos
Altera_Forum
Honored Contributor II
1,478 Views

You have to define sel as a bit vector. Now it's a single bit. 

sel; 

Then the mux code should work. 

 

It has been a nice idea to extend the conditional operator to multiple alternatives in your previous example. Unfortunately the Verilog standard doesn't know it.
0 Kudos
Altera_Forum
Honored Contributor II
1,478 Views

Cancelled:cry::cry::cry::cool:

0 Kudos
Altera_Forum
Honored Contributor II
1,478 Views

sel is an input, not of the reg type.

0 Kudos
Altera_Forum
Honored Contributor II
1,478 Views

Cancelled:cry::cry::cry::cool:

0 Kudos
Altera_Forum
Honored Contributor II
1,478 Views

A simple bit signal can only display values 0 and 1.

0 Kudos
Altera_Forum
Honored Contributor II
1,478 Views

Cancelled:cry::cry::cry::cool:

0 Kudos
Reply