Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

verilog questions generating name, this is a working program my question is can

ID: 3828667 • Letter: V

Question

verilog questions generating name,
this is a working program my question is
can someone please explain how one gets the values for the or section

// name.v
// pattern generator, generates program author's fullname
// output: Weide Chang

module TestMod;
   reg clk;
   wire [0:11] q;
   wire [6:0] ascii;

   initial begin
      #1;
      forever begin // this is clock wave
         clk = 0; // 0 for half cycle (#1)
         #1;
         clk = 1; // 1 for half cycle (#1)
         #1;
      end
   end

   RippleMod my_ripple(clk, q);
   EncoderMod my_coder(q, ascii);

   initial #27 $finish;

   initial begin
      $display("Time CLK   Q            Name");
      $monitor("%4d   %b    %b   %c", $time, clk, q, ascii);
   end
endmodule

module EncoderMod(q, ascii); // reverse 2x4 decoder
   input [0:11] q;           // input unary bits
   output [6:0] ascii;       // coded bits

//    q[i] ASCII 654 3210 Hex
//               vvv vvvv
//    q[0]   W   101 0111 57
//    q[1]   e   110 0101 65
//    q[2]   i   110 1001 69
//    q[3]   d   110 0100 64
//    q[4]   e   110 0101 65
//    q[5]       001 0000 20
//    q[6]   C   100 0011 43
//    q[7]   h   110 1000 68
//    q[8]   a   110 0001 61
//    q[9]   n   110 1110 6E
//    q[10] g   110 0111 67
//    q[11]      001 0000 20

//*************please explain this section
   or(ascii[0], q[0], q[1], q[2], q[4], q[6], q[8], q[10]);
   or(ascii[1], q[0], q[6], q[9], q[10]);
   or(ascii[2], q[0], q[1], q[3], q[4], q[9], q[10]);
   or(ascii[3], q[2], q[7], q[9]);
   or(ascii[4], q[0], q[5]);
   or(ascii[5], q[1], q[2], q[3], q[4], q[7], q[8], q[9], q[10]);
   nor(ascii[6], q[5], q[11]);
endmodule

module RippleMod(CLK, Q);
   input CLK;
   output [0:11] Q;

   reg [0:11] Q;      // flipflops

// try using = below instead and see what happens
   always @(CLK) begin
      Q[0] <= Q[11];   // at posedge clk event
      Q[1] <= Q[0];   // <= is concurrent transfer
      Q[2] <= Q[1];   // right side of <= is current
      Q[3] <= Q[2];   // left side of <= is future
      Q[4] <= Q[3];
      Q[5] <= Q[4];
      Q[6] <= Q[5];
      Q[7] <= Q[6];
      Q[8] <= Q[7];
      Q[9] <= Q[8];
      Q[10] <= Q[9];
      Q[11] <= Q[10];
   end

   initial Q = 12'b1000_0000_0000;
endmodule

Explanation / Answer

The or section of the code is only for encoding purpose:

In order to generate ascii code : q[i] ASCII 654 3210 Hex

we need to get the corresponding ascii values accordingly. the 7 ascii values given above are generated using below or and nor section.

or(ascii[0], q[0], q[1], q[2], q[4], q[6], q[8], q[10]);


   or(ascii[1], q[0], q[6], q[9], q[10]);
   or(ascii[2], q[0], q[1], q[3], q[4], q[9], q[10]);
   or(ascii[3], q[2], q[7], q[9]);
   or(ascii[4], q[0], q[5]);
   or(ascii[5], q[1], q[2], q[3], q[4], q[7], q[8], q[9], q[10]);
   nor(ascii[6], q[5], q[11]);