Sequential Circuits Constructive Computer Architecture Arvind

Slides:



Advertisements
Similar presentations
Combinational Circuits in Bluespec
Advertisements

Stmt FSM Richard S. Uhler Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology (based on a lecture prepared by Arvind)
Asynchronous Pipelines: Concurrency Issues Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology October 13, 2009http://csg.csail.mit.edu/koreaL12-1.
February 21, 2007http://csg.csail.mit.edu/6.375/L07-1 Bluespec-4: Architectural exploration using IP lookup Arvind Computer Science & Artificial Intelligence.
March, 2007http://csg.csail.mit.edu/arvindIPlookup-1 IP Lookup Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology.
September 24, L08-1 IP Lookup: Some subtle concurrency issues Arvind Computer Science & Artificial Intelligence Lab.
December 10, 2009 L29-1 The Semantics of Bluespec Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute.
Computer Architecture: A Constructive Approach Sequential Circuits Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology.
December 12, 2006http://csg.csail.mit.edu/6.827/L24-1 Scheduling Primitives for Bluespec Arvind Computer Science & Artificial Intelligence Lab Massachusetts.
Pipelining combinational circuits Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology February 20, 2013http://csg.csail.mit.edu/6.375L05-1.
September 3, 2009L02-1http://csg.csail.mit.edu/korea Introduction to Bluespec: A new methodology for designing Hardware Arvind Computer Science & Artificial.
Introduction to Bluespec: A new methodology for designing Hardware Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology.
Folded Combinational Circuits as an example of Sequential Circuits Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology.
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
March 6, 2006http://csg.csail.mit.edu/6.375/L10-1 Bluespec-4: Rule Scheduling and Synthesis Arvind Computer Science & Artificial Intelligence Lab Massachusetts.
Oct 2, 2014T01-1http://csg.csail.mit.edu/6.175 Constructive Computer Architecture Tutorial 1 BSV Sizhuo Zhang TA.
Constructive Computer Architecture: Guards Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology September 24, 2014.
September 22, 2009http://csg.csail.mit.edu/koreaL07-1 Asynchronous Pipelines: Concurrency Issues Arvind Computer Science & Artificial Intelligence Lab.
Constructive Computer Architecture Sequential Circuits Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology
Elastic Pipelines: Concurrency Issues Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology February 28, 2011L08-1http://csg.csail.mit.edu/6.375.
Constructive Computer Architecture Sequential Circuits Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology September.
Introduction to Bluespec: A new methodology for designing Hardware Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology.
Constructive Computer Architecture Sequential Circuits - 2 Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology.
Constructive Computer Architecture: Control Hazards Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology October.
February 20, 2009http://csg.csail.mit.edu/6.375L08-1 Asynchronous Pipelines: Concurrency Issues Arvind Computer Science & Artificial Intelligence Lab Massachusetts.
Modular Refinement Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology March 8,
Introduction to Bluespec: A new methodology for designing Hardware Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology.
October 20, 2009L14-1http://csg.csail.mit.edu/korea Concurrency and Modularity Issues in Processor pipelines Arvind Computer Science & Artificial Intelligence.
Elastic Pipelines: Concurrency Issues
EHRs: Designing modules with concurrent methods
Lecture 7: Sequential Networks
Concurrency properties of BSV methods and rules
Folded Combinational Circuits as an example of Sequential Circuits
Bluespec-6: Modeling Processors
Folded “Combinational” circuits
Scheduling Constraints on Interface methods
Sequential Circuits - 2 Constructive Computer Architecture Arvind
Learning Outcome By the end of this chapter, students are expected to be able to: Design State Machine Write Verilog State Machine by Boolean Algebra and.
EEL 3705 / 3705L Digital Logic Design
Sequential Circuits: Constructive Computer Architecture
Stmt FSM Arvind (with the help of Nirav Dave)
Pipelining combinational circuits
Multirule Systems and Concurrent Execution of Rules
Constructive Computer Architecture: Guards
Lecture 7: Sequential Networks
Sequential Circuits Constructive Computer Architecture Arvind
Pipelining combinational circuits
EHR: Ephemeral History Register
Bluespec-4: Architectural exploration using IP lookup Arvind
Constructive Computer Architecture: Well formed BSV programs
Modeling Processors: Concurrency Issues
Modules with Guarded Interfaces
Pipelining combinational circuits
CSE 370 – Winter Sequential Logic - 1
Sequential Circuits - 2 Constructive Computer Architecture Arvind
Elastic Pipelines: Concurrency Issues
Stmt FSM Arvind (with the help of Nirav Dave)
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
IP Lookup: Some subtle concurrency issues
Computer Science & Artificial Intelligence Lab.
Elastic Pipelines: Concurrency Issues
Elastic Pipelines and Basics of Multi-rule Systems
Constructive Computer Architecture: Guards
Elastic Pipelines and Basics of Multi-rule Systems
Multirule systems and Concurrent Execution of Rules
Introduction to Bluespec: A new methodology for designing Hardware
Sequential Logic.
Modular Refinement Arvind
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
Constructive Computer Architecture: Well formed BSV programs
Presentation transcript:

Sequential Circuits Constructive Computer Architecture Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology (Andy) Changed course website to correct website September 14, 2016 http://csg.csail.mit.edu/6.175

Combinational circuits Sel O A0 A1 An-1 Mux . lg(n) Sel O0 O1 On-1 A Demux . lg(n) OpSelect - Add, Sub, ... - And, Or, Xor, Not, ... - GT, LT, EQ, Zero, ... Result Comp? A B ALU A Decoder . O0 O1 On-1 lg(n) Such circuits have no cycles (feedback) or state elements September 14, 2016 http://csg.csail.mit.edu/6.175

Flip flop: The basic building block of Sequential Circuits Edge-Triggered Flip-flop D Q ff C C D Metastability? Q Metastability Data is sampled at the rising edge of the clock September 14, 2016 http://csg.csail.mit.edu/6.175

Flip-flops with Write Enables ff Q D C EN ff Q D C EN dangerous! ff Q D C EN 1 C D Q EN Why dangerous? Glitches Data is captured only if EN is on September 14, 2016 http://csg.csail.mit.edu/6.175

Registers Register: A group of flip-flops with a common D Q C En Register: A group of flip-flops with a common clock and enable Register file: A group of registers with a common clock, input and output port(s) September 14, 2016 http://csg.csail.mit.edu/6.175

An example Modulo-4 counter 00 01 10 11 inc=1 inc=0 Prev State NextState q1q0 inc = 0 inc = 1 00 01 10 11 State diagram – replace Cnt by inc q0t+1 = ~inc∙q0t + inc∙~q0t q1t+1 = ~inc∙q1t + inc∙~q1t∙q0t + inc∙q1t∙~q0t September 14, 2016 http://csg.csail.mit.edu/6.175

Modulo-4 counter circuit q0 inc 1 q1 Modulo-4 counter inc Read the q0t+1 = ~inc∙q0t + inc∙~q0t q1t+1 = ~inc∙q1t + inc∙~q1t∙q0t + inc∙q1t∙~q0t “Optimized” logic q0t+1 = inc  q0t q1t+1 = (inc == 1) ? q0t  q1t : q1t September 14, 2016 http://csg.csail.mit.edu/6.175

Finite State Machines (Sequential Ckts) A computer (in fact all digital hardware) is an FSM Neither State tables nor diagrams are suitable for describing very large digital designs large circuits must be described in a modular fashion -- as a collection of cooperating FSMs BSV is a modern programming language to describe cooperating FSMs We will give various examples of FSMs in BSV September 14, 2016 http://csg.csail.mit.edu/6.175

modulo4 counter in BSV Can be replaced by cnt+1 inc.en read cnt module moduloCounter(Counter); Reg#(Bit#(2)) cnt <- mkReg(0); method Action inc;       cnt <={~cnt[1]&cnt[0] | cnt[1]&~cnt[0], ~cnt[0]}; endmethod method Bit#(2) read; return cnt; endmodule Can be replaced by cnt+1 ~cnt[1]&… inc.en read cnt (Andy) ‘r’ and ‘w’ are ‘_read’ and ‘_write’ in BSV, but ‘r’ and ‘w’ are much easier to write on slides. (Andy) I changed ‘||’ to ‘|’ in the logic because || is the boolean or and | is the bitwise or. September 14, 2016 http://csg.csail.mit.edu/6.175

Interface Modulo counter has the following interface, i.e., type An interface can have many different implementations For example, the numbers may be represented as Gray code interface Counter; method Action inc; method Bit#(2) read; endinterface September 14, 2016 http://csg.csail.mit.edu/6.175

FIFO Interface interface Fifo#(numeric type size, type t); method Bool notFull; method Bool notEmpty; method Action enq(t x); method Action deq; method t first; endinterface x en enq deq module Fifo !full !emty first notFull notEmpty - enq should be called only if notFull returns True; - deq and first should be called only if notEmpty returns True September 14, 2016 http://csg.csail.mit.edu/6.175

One-Element FIFO Implementation module mkCFFifo (Fifo#(1, t)); Reg#(t) d <- mkRegU; Reg#(Bool) v <- mkReg(False); method Bool notFull; return !v; endmethod method Bool notEmpty; return v; method Action enq(t x); v <= True; d <= x; method Action deq; v <= False; method t first; return d; endmodule x en enq deq module Fifo !full !emty first notFull notEmpty September 14, 2016 http://csg.csail.mit.edu/6.175

parallel composition of actions Two-Element FIFO db da module mkCFFifo (Fifo#(2, t)); Reg#(t) da <- mkRegU(); Reg#(Bool) va <- mkReg(False); Reg#(t) db <- mkRegU(); Reg#(Bool) vb <- mkReg(False); method Bool notFull; return !vb; endmethod method Bool notEmpty; return va; endmethod method Action enq(t x); if (va) begin db <= x; vb <= True; end else begin da <= x; va <= True; end endmethod method Action deq; if (vb) begin da <= db; vb <= False; end else begin va <= False; end method t first; return da; endmethod endmodule Assume, if there is only one element in the FIFO it resides in da parallel composition of actions no change in fifo interface September 14, 2016 http://csg.csail.mit.edu/6.175

Switch inQ redQ greenQ parallel composition of actions. Effect of inQ.deq is not visible to inQ.first if (inQ.first.color == Red) begin redQ.enq(inQ.first.value); inQ.deq; end else begin greenQ.enq(inQ.first.value); inQ.deq; end Effect of inQ.deq is not visible to inQ.first The code does not test for empty inQ or full redQ or full greenQ conditions! let x = inQ.first; if (x.color == Red) redQ.enq(x.value); else greenQ.enq(x.value); inQ.deq; September 14, 2016 http://csg.csail.mit.edu/6.175

Switch with empty/full tests on queues inQ redQ greenQ if (inQ.notEmpty) begin if (inQ.first.color == Red) begin if (redQ.notFull) begin redQ.enq(inQ.first.value); inQ.deq; end end else begin if (greenQ.notFull) begin greenQ.enq(inQ.first.value); inQ.deq; Atomicity violation! inQ.deq; end What’s wrong if the deq is moved here? September 14, 2016 http://csg.csail.mit.edu/6.175

Switch with counters inQ redQ greenQ redC greenC if (inQ.first.color == Red) begin redQ.enq(inQ.first.value); inQ.deq; redC <= redC+1; end else begin greenQ.enq(inQ.first.value); inQ.deq; greenC <= greenC+1; end (Andy) Changed code to conform with BSV syntax Ignoring full/empty conditions September 14, 2016 http://csg.csail.mit.edu/6.175

Shared counters inQA redQA greenQA redC greenC inQB redQB greenQB if (inQA.first.color == Red) begin redQA.enq(inQA.first.value); inQA.deq; redC <= redC+1; end else begin greenQA.enq(inQA.first.value); inQA.deq; greenC <= greenC+1; end; if (inQB.first.color == Red) begin redQB.enq(inQB.first.value); inQB.deq; redC <= redC+1; greenQB.enq(inQB.first.value); inQB.deq; greenC <= greenC+1; end inQA redQA greenQA redC greenC inQB redQB greenQB (Andy) Changed code to conform with BSV syntax Ignoring full/empty conditions What is wrong with this code? Double write error September 14, 2016 http://csg.csail.mit.edu/6.175

Double-write problem Parallel composition is illegal if a double-write possibility exists If the BSV compiler cannot prove that the predicates for writes into a register or a method call are mutually exclusive, it rejects the program September 14, 2016 http://csg.csail.mit.edu/6.175

Observations These programs are not very complex and yet it would have been tedious to express these programs in a state table or as a circuit directly BSV method calls are not available in Verilog/VHDL, and thus such programs sometimes require tedious programming Even the meaning of double-write errors is not standardized across tool implementations in Verilog September 14, 2016 http://csg.csail.mit.edu/6.175