Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CPEN 211 Introduction to Microcomputers, 2019

Lab Proficiency Test #1

Question 1 [2 marks]:  Create a file named “q1.v” and inside it write synthesizable Verilog that implements a combinational logic module matching the specification below.   Your  top-level module must be called “detect_winner” and it must be declared exactly as follows:

module detect_winner(a in, bin, cin, f, valid);

input [8:0] a in, bin, cin;

output [2:0] f;

output valid;

You earn 1 mark each for matching the specifications given below for f and valid.  Your q1.v file must include definitions for any modules instantiated inside detect_winner (even code provided in slides, labs or textbook).   You  should test your code. You can include testbench modules in q1.v, but testbench modules inside q1.v will be ignored.  Submit your q1.v via “Lab Proficiency Test #1” on Canvas before 6:50 pm, when the site closes. In case your computer’s time  differs  from  Canvas  submit  early  and  resubmit  as  needed.      Do  NOT  “zip”  your submission. The file you upload for this question must be called “q1.v” .   If you resubmit and Canvas renames your file to “q1-N.v” that is OK. You get zero if any of the following are true:

1.   Your last “Lab Proficiency Test #1” attempt on Canvas does not include “q1.v”, 2.   Your q1.v file does not compile using ModelSim (e.g., due to syntax errors),

3.   Your detect_winner cannot be simulated in ModelSim, using only q1.v,

4.   The Verilog used by detect_winner is not synthesizable or has inferred latches.

Specification: Each bit of “ a in”, “ bin”, and “cin”, corresponds to one square in the gameboard  in Figure 1(a).  A one in position n of “ain” indicates player A has placed a piece in square n.  Similarly, position n of “bin”, “ cin” indicates board positions for player B, C. A player “wins” if they get a piece in square 0, 3 or 6. Regardless of whether the board is valid, output a ‘1’ on  f[0] if A has a piece in 0, 3 or 6; output a ‘1’ on f[1] if  B has a piece in 0, 3 or 6;  and, output  a ‘1’ on f[2] if C has a piece in 0, 3 or 6.  A valid board configuration satisfies two rules: (1) No  square should be occupied by more than one player; (2)  To occupy a square other than 2, 5, or 8,  someone (not necessarily the same player) must occupy the adjacent square in the direction closer  to the center of the board (where the black circle is). E.g., for A to occupy 1, either A, B or C must  occupy 2.  Similarly, for A to occupy 0 either A, B or C must occupy 1 and either A, B or C must  occupy 2. Output valid should be ‘1’ if and only if the board contains a valid board configuration.  Examples of inputs ain, bin, cin and corresponding f and valid are shown in Figure 1(b)  to (i).  Your solution must work for any input values (i.e., not just these ones).