1 / 11

V ERILOG

V ERILOG. 2. Μια πιο κοντινή ματιά. !. t 0 + period. t 0. Δομή της γλώσσας. `timescale 1ns / 1ns `define dh 2 `include “cwaves.h”. Μοιάζει πολύ με τη C Preprocessor Keywords Τελεστές Γλώσσα « event driven ». = ==, != <, >, <=, >= && || ? :. & and | or ~ not ^ xor.

lamont
Télécharger la présentation

V ERILOG

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. VERILOG 2. Μια πιο κοντινή ματιά

  2. ! t0 + period t0 Δομή της γλώσσας `timescale 1ns / 1ns `define dh 2 `include “cwaves.h” • Μοιάζει πολύ με τη C • Preprocessor • Keywords • Τελεστές • Γλώσσα «event driven» = ==, != <, >, <=, >= && || ? : & and | or ~ not ^ xor always clk = #(`period / 2) ~clk; always @(posedge clk) a = b + 1; always @(posedge clk) b = c + 1; Verilog - Λυμπέρης Σπύρος

  3. initial begin a = 0; b = 0; clk = 0; end always clk = #10 ~clk; wire comb = a + b; always @(posedge clk) a = b + 1; always @(posedge clk) b = c + 1; always @(posedge clk) c = #5 c + 1; 0 10, 20, 30, 40, 50 10+, 30+ 10, 30 10, 30 15, 35 0 20 30 10 40 50 Events • Κάθε έκφραση συνδέεται με έναν αρχικό χρόνο • Initial και always: εσωτερικά σειριακά Verilog - Λυμπέρης Σπύρος

  4. Case always @(posedge clk) begin case (opcode) 8’h0A: dstreg = #`dh inreg0; 8’h22: begin dstreg = #`dh a + 1; if (a | (b ^ (~c))) dstreg = #`dh inreg1; end 8’hFF: dstreg = #`dh inreg2; default: dstreg = #`dh 8’h00; endcase end • … το γνωστό case • Μόνο με σταθερές εκφράσεις • Δεν χρειάζεται break • Καλός κώδικας: • Μοναδικό αριστερό μέρος Verilog - Λυμπέρης Σπύρος

  5. 3 a 8 c 5 b Concatenation • «Hardwired» πράξεις… • … απαραίτητες σε μια HDL wire [2:0] a; wire [4:0] b; wire [7:0] c = {a, b}; wire [7:0] unsigned; wire [15:0] sign_extend = { (unsigned[7] ? 8’hFF : 8’h0), unsigned}; Verilog - Λυμπέρης Σπύρος

  6. Μνήμες wire [15:0] word_in; wire [15:0] word_out; wire [9:0] addr; reg [15:0] memory [1023:0]; always @(posedge clk) begin if (we) memory[addr] = word_in; else word_out = memory[addr]; end • Αναδρομικά:array of array • Συνήθως non-synthesizable • Ειδική αρχικοποίηση always @(negedge reset_n) $readmemh(“memory.dat”, memory); Verilog - Λυμπέρης Σπύρος

  7. Δύναμη σημάτων • Προτεραιότητα: • Χ • 1 και 0 • Ζ • … και άλλα • Αρχικά όλα Χ • Προσοχή στην αρχικοποίηση initial ... always @(posedge clk) if (reset) ...else ... Verilog - Λυμπέρης Σπύρος

  8. Τρικατάστατοι οδηγητές • Χρήση του τύπου inout • Εκμετάλλευση της κατάστασης Ζ module tristate(en, clk, data); input en, clk; inout [7:0] data; wire [7:0] data = (en) ? data_out : 8’bz; always @(posedge clk) begin if (!en) case (data) ... endmodule wire [7:0] bus; tristate tr0(en0, clk, bus); tristate tr1(en1, clk, bus); tristate tr2(en2, clk, bus); Verilog - Λυμπέρης Σπύρος

  9. Παραμετρικά modules module RegLd(Q, D, load, clk); parameter N = 8; input [N-1:0] Q; output [N-1:0] D; input load, Clk; always @(posedge clk) if (load) Q = #`dh D; endmodule • Μπορούμε να έχουμε παραμέτρους σε ένα module • Default μέγεθος • … πολύ βολικό! RegLd reg0(q0, d0, l, clk); RegLd #16 reg1(q1, d1, l, clk); RegLd reg2(q2, d2, l, clk); defparam reg2.N = 4; Verilog - Λυμπέρης Σπύρος

  10. ! Sensitivity lists • Λογικές εκφράσεις με or, and • posedge και negedge • Ρολόγια • Προσοχή στο hardware που θέλουμε να περιγράψουμε… always @(posedge clk or negedge rst_) ... always @(a or b or c) if (opcode == 32’h52A0234E) a = b ^ (~c); always @(posedge a or posedge b) ... Verilog - Λυμπέρης Σπύρος

  11. Τέλος! • Tρικατάστατοι • wire a = (en) ? 1’b1: 1’bz; • Parameters • parameter N = 16; • Reg #8 r0(…); • Sensitivity lists • always @(a or b); • always @(negedge rst_); • Preprocessor • `define • `timescale • `include • Concatenations • {a, b, c} • Case • case … endcase • default • Μνήμες • reg [15:0] rf [7:0]; Verilog - Λυμπέρης Σπύρος

More Related