From d9f8744ea219fb04057059cdcbf7162534c63852 Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Tue, 7 Jan 2014 15:07:22 +0100 Subject: Document. --- cpu/alu.ml | 2 +- cpu/cpu.ml | 4 +++- cpu/netlist_gen.ml | 9 +++------ cpu/netlist_gen.mli | 2 -- 4 files changed, 7 insertions(+), 10 deletions(-) (limited to 'cpu') diff --git a/cpu/alu.ml b/cpu/alu.ml index e0c1ef9..f437bd3 100644 --- a/cpu/alu.ml +++ b/cpu/alu.ml @@ -51,7 +51,7 @@ let rec nadder_with_carry n a b c_in = let nadder n a b = let a, b = nadder_with_carry n a b (const "0") in - ignore b a + b ^. a let rec nsubber n a b = zeroes n (* TODO *) diff --git a/cpu/cpu.ml b/cpu/cpu.ml index 541e364..94cc47c 100644 --- a/cpu/cpu.ml +++ b/cpu/cpu.ml @@ -17,6 +17,7 @@ let cpu_ram ra we wa d = 0x8000 to 0xFFFF is RAM *) let read_data = zeroes 8 in + (* ROM chip *) let ra_hi1 = ra ** 15 in let ra_lo1 = ra % (0, 14) in let ra_hi2 = ra ** 14 in @@ -25,7 +26,7 @@ let cpu_ram ra we wa d = let rd_rom = rom "ROM0" 14 8 ra_lo2 in let read_data = mux read_rom read_data rd_rom in - + (* RAM chip *) let read_ram = ra_hi1 in let wa_hi1 = wa ** 15 in let wa_lo1 = wa % (0, 14) in @@ -33,6 +34,7 @@ let cpu_ram ra we wa d = let rd_ram = ram 15 8 ra_lo1 we_ram wa_lo1 d in let read_data = mux read_ram read_data rd_ram in + (* MMIO *) let read_tick = eq_c 16 ra 0x4000 in let next_tick, save_next_tick = loop 8 in let tick = nadder 8 (reg 8 next_tick) (get "tick" ++ zeroes 7) in diff --git a/cpu/netlist_gen.ml b/cpu/netlist_gen.ml index 1aad452..016c595 100644 --- a/cpu/netlist_gen.ml +++ b/cpu/netlist_gen.ml @@ -16,9 +16,8 @@ let add p id eq size = assert (not (Env.mem id p.p_vars) || (Env.find id p.p_vars = size)); assert (not (List.mem_assoc id p.p_eqs)); - { p_eqs = (id, eq)::p.p_eqs; - p_inputs = p.p_inputs; - p_outputs = p.p_outputs; + { p with + p_eqs = (id, eq)::p.p_eqs; p_vars = Env.add id size p.p_vars } let get id = @@ -195,9 +194,7 @@ let program entries outputs = p, outputs) (p, []) outputs in - { p_inputs = p.p_inputs; - p_eqs = p.p_eqs; - p_vars = p.p_vars; + { p with p_outputs = List.rev outputs } diff --git a/cpu/netlist_gen.mli b/cpu/netlist_gen.mli index 280ee8c..67d4774 100644 --- a/cpu/netlist_gen.mli +++ b/cpu/netlist_gen.mli @@ -2,8 +2,6 @@ type t val print : out_channel -> Netlist_ast.program -> unit -val id : string -> Netlist_ast.ident - val get : Netlist_ast.ident -> t val loop : int -> (t * (t -> t)) -- cgit v1.2.3