Sequential Circuits: Constructive Computer Architecture

Slides:



Advertisements
Similar presentations
Constructive Computer Architecture: Multirule systems and Concurrent Execution of Rules Arvind Computer Science & Artificial Intelligence Lab. Massachusetts.
Advertisements

March 2007http://csg.csail.mit.edu/arvindSemantics-1 Scheduling Primitives for Bluespec Arvind Computer Science & Artificial Intelligence Lab Massachusetts.
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.
IP Lookup: Some subtle concurrency issues Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology February 22, 2011L06-1.
IP Lookup: Some subtle concurrency issues Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology March 4, 2013
December 10, 2009 L29-1 The Semantics of Bluespec Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute.
ECE 2372 Modern Digital System Design
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.
March 6, 2006http://csg.csail.mit.edu/6.375/L10-1 Bluespec-4: Rule Scheduling and Synthesis Arvind Computer Science & Artificial Intelligence Lab Massachusetts.
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
Introduction to ASIC flow and Verilog HDL
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.
February 20, 2009http://csg.csail.mit.edu/6.375L08-1 Asynchronous Pipelines: Concurrency Issues Arvind Computer Science & Artificial Intelligence Lab Massachusetts.
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.
Introduction to Bluespec: A new methodology for designing Hardware
Introduction to Bluespec: A new methodology for designing Hardware
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
Sequential Circuits 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.
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
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
Modules with Guarded Interfaces
Pipelining combinational circuits
Sequential Circuits - 2 Constructive Computer Architecture Arvind
Introduction to Bluespec: A new methodology for designing Hardware
Stmt FSM Arvind (with the help of Nirav Dave)
CSE 370 – Winter Sequential Logic-2 - 1
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
IP Lookup: Some subtle concurrency issues
Elastic Pipelines and Basics of Multi-rule Systems
Constructive Computer Architecture: Guards
Elastic Pipelines and Basics of Multi-rule Systems
Control Hazards Constructive Computer Architecture: Arvind
Multirule systems and Concurrent Execution of Rules
Introduction to Bluespec: A new methodology for designing Hardware
Sequential Logic.
IP Lookup: Some subtle concurrency issues
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
Constructive Computer Architecture: Well formed BSV programs
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
Presentation transcript:

Sequential Circuits: Constructive Computer Architecture Circuits with state Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology (Andy) Changed course website to correct website September 13, 2017 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 13, 2017 http://csg.csail.mit.edu/6.175

Edge-Triggered Flip flop: the basic storage element ff Q D C Unstable data C D Metastability Q Metastability? Data is sampled at the rising edge of the clock and must be stable at that time September 13, 2017 http://csg.csail.mit.edu/6.175

Flip-flops with Write Enables: The building block of Sequential Circuits ff Q D C EN 1 ff Q D C EN EN D Qt Qt+1 X 1 C D Q EN hold Why dangerous? Glitches copy input Data is captured only if EN is on No need to show clock explicitly September 13, 2017 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 13, 2017 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 Finite State Machine (FSM) representation State diagram – replace Cnt by inc q0t+1 = ~inc∙q0t + inc∙~q0t = inc  q0t q1t+1 = ~inc∙q1t + inc∙~q1t∙q0t + inc∙q1t∙~q0t = (inc == 1) ? q0t  q1t : q1t September 13, 2017 http://csg.csail.mit.edu/6.175

Finite State Machines (FSM) and Sequential Ckts FSMs are a mathematical object like the Boolean Algebra A computer (in fact any digital hardware) is an FSM Synchronous Sequential Circuits is a method to implement FSMs in hardware Large circuits need to be described as a collection of cooperating FSMs State diagrams and next-state tables are not suitable for such descriptions output input Combinational logic state Next state clock September 13, 2017 http://csg.csail.mit.edu/6.175

Modulo-4 counter in BSV interface Counter; method Action inc; 2 read 2 interface Counter; method Action inc; method Bit#(2) read; endinterface State specification module moduloCounter(Counter); Reg#(Bit#(2)) cnt <- mkReg(0); method Action inc;       cnt <={cnt[1]^cnt[0],~cnt[0]}; endmethod method Bit#(2) read; return cnt; endmodule Initial value An action to specify how the value of the cnt is to be set September 13, 2017 http://csg.csail.mit.edu/6.175

Modules A module in BSV is like a class definition in Java or C++ It has internal state The internal state can only be read and manipulated by the (interface) methods An action specifies which state elements are to be modified Actions are atomic -- either all the specified state elements are modified or none of them are modified (no partially modified state is visible) interface Counter; method Action inc; method Bit#(2) read; endinterface September 13, 2017 http://csg.csail.mit.edu/6.175

Inside the Modulo-4 counter 1 2 inc read cnt0 cnt1 module moduloCounter(Counter); Reg#(Bit#(2)) cnt <- mkReg(0); method Action inc;       cnt <={cnt[1]^cnt[0],~cnt[0]}; endmethod method Bit#(2) read; return cnt; endmodule September 13, 2017 http://csg.csail.mit.edu/6.175

Examples September 13, 2017 http://csg.csail.mit.edu/6.175

A hardware module for computing GCD Euclid’s algorithm for computing the Greatest Common Divisor (GCD): 15 6 9 6 subtract 3 6 subtract 6 3 swap 3 3 subtract 0 3 subtract answer gcd (a,b) = if a==0 then b \\ stop else if a>=b then gcd(a-b,b) \\ subtract else gcd (b,a) \\ swap September 13, 2017 http://csg.csail.mit.edu/6.175

GCD module GCD can be started if the module is not busy; getResult ready data result GCD can be started if the module is not busy; Results can be read when ready en en interface GCD; method Action start (Bit#(32) a, Bit#(32) b); method ActionValue#(Bit#(32)) getResult; method Bool busy; method Bool ready; endinterface September 13, 2017 http://csg.csail.mit.edu/6.175

GCD in BSV start should be called only if the module is not busy; module mkGCD (GCD); Reg#(Bit#(32)) x <- mkReg(0); Reg#(Bit#(32)) y <- mkReg(0); Reg#(Bool) busy_flag <- mkReg(False); rule gcd; if (x >= y) begin x <= x – y; end //subtract else if (x != 0) begin x <= y; y <= x; end //swap endrule method Action start(Bit#(32) a, Bit#(32) b); x <= a; y <= b; busy_flag <= True; endmethod method ActionValue#(Bit#(32)) getResult; busy_flag <= False; return y; method busy = busy_flag; method ready = x==0; endmodule Assume b /= 0 start should be called only if the module is not busy; getResult should be called only when ready is true. September 13, 2017 http://csg.csail.mit.edu/6.175

parallel composition of actions Rule parallel composition of actions A module may contain rules rule gcd; if (x >= y) begin x <= x – y; end //subtract else if (x != 0) begin x <= y; y <= x; end //swap endrule A rule is a collection of actions, which invoke methods All actions in a rule execute in parallel A rule can execute any time and when it executes all of its actions must execute atomicity September 13, 2017 http://csg.csail.mit.edu/6.175

Parallel Composition of Actions & Double-Writes rule one; y <= 3; x <= 5; x <= 7; endrule Double write rule two; y <= 3; if (b) x <= 7; else x <= 5; endrule No double write rule three; y <= 3; x <= 5; if (b) x <= 7; endrule Possibility of a double write Parallel composition, and consequently a rule containing it, is illegal if a double-write possibility exists The BSV compiler rejects a program if it there is a possibility of a double write September 13, 2017 http://csg.csail.mit.edu/6.175

Defining FIFOs and it’s uses September 13, 2017 http://csg.csail.mit.edu/6.175

FIFO Module 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 13, 2017 http://csg.csail.mit.edu/6.175

An Implementation: One-Element FIFO module mkFifo (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 13, 2017 http://csg.csail.mit.edu/6.175

Streaming a function inQ f outQ rule stream; if(inQ.notEmpty && outQ.notFull) begin outQ.enq(f(inQ.first)); inQ.deq; end endrule Boolean & (“AND”) operation September 13, 2017 http://csg.csail.mit.edu/6.175

Streaming a module inQ outQ rule invokeGCD; start GCD busy result ready inQ invoke GCD get result outQ rule invokeGCD; if(inQ.notEmpty && !gcd.busy) begin gcd.start(inQ.first); inQ.deq; end endrule rule getResult; if(outQ.notFull && gcd.ready) begin x <- gcd.result; outQ.enq(x); end endrule Action value method September 13, 2017 http://csg.csail.mit.edu/6.175

Switch red messages go into redQ, green into greenQ inQ redQ greenQ switch red messages go into redQ, green into greenQ rule switch; if (inQ.first.color == Red) begin redQ.enq(inQ.first.value); inQ.deq; end else begin greenQ.enq(inQ.first.value); inQ.deq; end; endrule Effect of inQ.deq is not visible to inQ.first The code is not correct because it does not include tests for empty inQ or full redQ or full greenQ conditions! September 13, 2017 http://csg.csail.mit.edu/6.175

Switch with empty/full tests on queues - 1 inQ redQ greenQ switch rule switch; if (inQ.first.color == Red) begin redQ.enq(inQ.first.value); inQ.deq; end else begin greenQ.enq(inQ.first.value); inQ.deq; endrule first and deq operations can be performed only if inQ is not empty September 13, 2017 http://csg.csail.mit.edu/6.175

Switch with empty/full tests on queues -2 inQ redQ greenQ switch rule switch; if (inQ.notEmpty) if (inQ.first.color == Red) begin redQ.enq(inQ.first.value); inQ.deq; end else begin greenQ.enq(inQ.first.value); inQ.deq; endrule When can an enq operation be performed on redQ? September 13, 2017 http://csg.csail.mit.edu/6.175

Switch with empty/full tests on queues inQ redQ greenQ switch rule switch; if (inQ.notEmpty) if (inQ.first.color == Red) begin1 if (redQ.notFull) begin2 redQ.enq(inQ.first.value); inQ.deq; end2 end1 else begin3 if (greenQ.notFull) begin4 greenQ.enq(inQ.first.value); inQ.deq; end4 end3 endrule September 13, 2017 http://csg.csail.mit.edu/6.175

An optimization A wrong optimization inQ redQ switch greenQ rule switch; if (inQ.notEmpty) if (inQ.first.color == Red) begin1 if (redQ.notFull) begin2 redQ.enq(inQ.first.value); inQ.deq; end2 end1 else begin3 if (greenQ.notFull) begin4 greenQ.enq(inQ.first.value); inQ.deq; end4 endrule inQ value may get lost if redQ (or greenQ) is full Atomicity violation! inQ.deq; endrule Can we move the deq here? September 13, 2017 http://csg.csail.mit.edu/6.175

Observations These sample 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 The meaning of double-write errors is not standardized across Verilog tools Interface methods are not available in Verilog/VHDL September 13, 2017 http://csg.csail.mit.edu/6.175