//////////////////////////////////////////////////////////////////////////////// // /// LSU EE 4755 Fall 2019 Homework 4 // /// Assignment https://www.ece.lsu.edu/koppel/v/2019/hw04.pdf /// Instructions: // // (1) Find the undergraduate workstation laboratory, room 2241 Patrick // F. Taylor Hall. Machines to use are in the back. // // (2) Locate your account. If you did not get an account please // E-mail: koppel@ece.lsu.edu // // (3) Log in to a Linux workstation. // // (4) If you haven't already, follow the account setup instructions here: // https://www.ece.lsu.edu/koppel/v/proc.html // // (5) Copy this assignment, local path name // /home/faculty/koppel/pub/ee4755/hw/2019/hw04 // to a directory ~/hw04 in your class account. (~ is your home // directory.) Use this file for your solution. /// BE SURE THAT YOUR FILE IS CORRECTLY NAMED AND IN THE RIGHT PLACE. // // (6) Find the problems in this file and solve them. // // Your entire solution should be in this file. // // Do not change module names. // // (7) Your solution will automatically be copied from your account by // the TA-bot. /// Additional Resources // // Verilog Documentation // The Verilog Standard // https://ieeexplore.ieee.org/document/8299595/ // Introductory Treatment (Warning: Does not include SystemVerilog) // Brown & Vranesic, Fundamentals of Digital Logic with Verilog, 3rd Ed. // // Account Setup and Emacs (Text Editor) Instructions // https://www.ece.lsu.edu/koppel/v/proc.html // To learn Emacs look for Emacs tutorial. // // Unix Help (Very outdated. Alternatives welcome.) // https://www.ece.lsu.edu/koppel/v/4ltrwrd/ `default_nettype none ////////////////////////////////////////////////////////////////////////////// /// Problem 1 // /// Complete best_match so that it computes the best_match over wv cycles. // // [ ] Put your solution in best_match. No other modules should // be modified. (Except the testbench, to help debug.) // // [ ] Set the ready output to 0 when start is 1 at a positive edge .. // .. and set it to 1 when pos and err are available. // // [ ] best_match should take about wv - wk cycles (see the params) // to find |pos| and |err|. // // [ ] best_match must use a pop module to compute err. // // [ ] Avoid designs that use a non-constant shifter or large mux. // // [ ] Make sure that the testbench does not report errors. // [ ] Module must be synthesizable. Use command: genus -files syn.tcl // // [ ] As always, avoid costly, slow, and confusing code. // [ ] As always, don't assume parameters will be at their default values. module best_match #( int wv = 32, int wk = 10, int wvb = $clog2(wv), int wkv = $clog2(wk+1) ) ( output logic [wvb:1] pos, output logic [wkv:1] err, output logic ready, input uwire [wv-1:0] val, input uwire [wk-1:0] k, input uwire start, clk ); // Put your solution here. endmodule // Use this design for reference. module best_match_behavioral #( int wv = 32, int wk = 10, int wvb = $clog2(wv), int wkv = $clog2(wk+1) ) ( output logic [wvb:1] pos, // Position of best match. output logic [wkv:1] err, // Number of non-matching bits. input uwire [wv-1:0] val, input uwire [wk-1:0] k ); always_comb begin automatic int best_err = wk + 1; automatic int best_pos = -1; for ( int p=0; p<=wv-wk; p++ ) begin automatic int e = 0; for ( int b=0; b