From aaa63d9cb5260e96688dbd13a8e82ac0e7322321 Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 26 Aug 2007 11:51:19 +0100 Subject: [PATCH] final pass to update instruction encoding; should now match the spec --- {src/edu/berkeley/fleet => contrib}/f0/Compile.lhs | 0 {src/edu/berkeley/fleet => contrib}/f0/Fleet.lhs | 0 {src/edu/berkeley/fleet => contrib}/f0/Main.lhs | 0 {src/edu/berkeley/fleet => contrib}/f0/Types.lhs | 0 {src/edu/berkeley/fleet => contrib}/f0/Util.lhs | 0 {src/edu/berkeley/fleet => contrib}/f0/f0.g | 0 ships/Alu2.ship | 7 - ships/Lut3.ship | 7 +- src/edu/berkeley/fleet/api/Instruction.java | 110 ++++++------- src/edu/berkeley/fleet/assembler/Parser.java | 23 +-- src/edu/berkeley/fleet/assembler/fleet.g | 4 +- src/edu/berkeley/fleet/doc/Doc.java | 2 +- src/edu/berkeley/fleet/fpga/Fpga.java | 4 +- src/edu/berkeley/fleet/fpga/Generator.java | 61 ++++---- .../berkeley/fleet/ies44/InstructionEncoder.java | 162 ++++++++++---------- .../berkeley/fleet/interpreter/Interpreter.java | 15 +- src/edu/berkeley/fleet/interpreter/Outbox.java | 3 + .../fleet/{ies44 => util}/BitManipulations.java | 3 +- tests/literals/negative-absolute-literals.fleet | 3 +- tests/pump/kill-only-standing-instructions.fleet | 7 +- tests/pump/token-on-last-iteration.fleet | 21 +++ .../requeue-expire.fleet} | 4 +- tests/requeue/requeueing-literal.fleet | 27 ++++ .../test-requeue.fleet} | 8 +- 24 files changed, 254 insertions(+), 217 deletions(-) rename {src/edu/berkeley/fleet => contrib}/f0/Compile.lhs (100%) rename {src/edu/berkeley/fleet => contrib}/f0/Fleet.lhs (100%) rename {src/edu/berkeley/fleet => contrib}/f0/Main.lhs (100%) rename {src/edu/berkeley/fleet => contrib}/f0/Types.lhs (100%) rename {src/edu/berkeley/fleet => contrib}/f0/Util.lhs (100%) rename {src/edu/berkeley/fleet => contrib}/f0/f0.g (100%) rename src/edu/berkeley/fleet/{ies44 => util}/BitManipulations.java (94%) create mode 100644 tests/pump/token-on-last-iteration.fleet rename tests/{recycle/test-recycle-expire.fleet => requeue/requeue-expire.fleet} (92%) create mode 100644 tests/requeue/requeueing-literal.fleet rename tests/{recycle/test-recycle.fleet => requeue/test-requeue.fleet} (93%) diff --git a/src/edu/berkeley/fleet/f0/Compile.lhs b/contrib/f0/Compile.lhs similarity index 100% rename from src/edu/berkeley/fleet/f0/Compile.lhs rename to contrib/f0/Compile.lhs diff --git a/src/edu/berkeley/fleet/f0/Fleet.lhs b/contrib/f0/Fleet.lhs similarity index 100% rename from src/edu/berkeley/fleet/f0/Fleet.lhs rename to contrib/f0/Fleet.lhs diff --git a/src/edu/berkeley/fleet/f0/Main.lhs b/contrib/f0/Main.lhs similarity index 100% rename from src/edu/berkeley/fleet/f0/Main.lhs rename to contrib/f0/Main.lhs diff --git a/src/edu/berkeley/fleet/f0/Types.lhs b/contrib/f0/Types.lhs similarity index 100% rename from src/edu/berkeley/fleet/f0/Types.lhs rename to contrib/f0/Types.lhs diff --git a/src/edu/berkeley/fleet/f0/Util.lhs b/contrib/f0/Util.lhs similarity index 100% rename from src/edu/berkeley/fleet/f0/Util.lhs rename to contrib/f0/Util.lhs diff --git a/src/edu/berkeley/fleet/f0/f0.g b/contrib/f0/f0.g similarity index 100% rename from src/edu/berkeley/fleet/f0/f0.g rename to contrib/f0/f0.g diff --git a/ships/Alu2.ship b/ships/Alu2.ship index 400eb08..1020acf 100644 --- a/ships/Alu2.ship +++ b/ships/Alu2.ship @@ -23,13 +23,6 @@ Use carry-in bit to create a selector? Perhaps a waste of an ALU. Flags: zero, negative, overflow, ? -\begin{verbatim} -move elsewhere: -//MUL: -//DIV: -//MOD: -\end{verbatim} - == Fleeterpreter ==================================================== public long resolveLiteral(String literal) { if (literal.equals("ADD")) return 0; diff --git a/ships/Lut3.ship b/ships/Lut3.ship index 3692f7b..3274fe9 100644 --- a/ships/Lut3.ship +++ b/ships/Lut3.ship @@ -386,13 +386,14 @@ alu.in: deliver; [*] take, deliver; alu.out: - [*] nop; + clog; (*) wait, take, sendto lut.inLut; (*) sendto alu.in; - kill*; + unclog; // acks from debug ship trigger new truth tables -debug.in: [*] take, deliver, notify alu.out; +debug.in: + [*] take, deliver, notify alu.out; lut.inLut: literal 0; diff --git a/src/edu/berkeley/fleet/api/Instruction.java b/src/edu/berkeley/fleet/api/Instruction.java index e9a74b6..55e2b52 100644 --- a/src/edu/berkeley/fleet/api/Instruction.java +++ b/src/edu/berkeley/fleet/api/Instruction.java @@ -2,38 +2,54 @@ package edu.berkeley.fleet.api; public abstract class Instruction { - public static class Kill extends Instruction { - - public final Pump pump; - public final int count; - public final boolean killOnlyStandingInstructions; - public Kill(Pump pump, int count, boolean killOnlyStandingInstructions) { - this.pump=pump; - this.count=count; - this.killOnlyStandingInstructions = killOnlyStandingInstructions; - if (killOnlyStandingInstructions && count !=1) - throw new RuntimeException("currently, kill* must have count=1"); + public final Pump pump; + public Instruction(Pump pump) { this.pump = pump; } + public String toString() { return pump+": "; } + + public static abstract class CountingInstruction extends Instruction { + public final int count; + public CountingInstruction(Pump pump, int count) { + super(pump); + this.count = count; } - public String toString() { return (count>1 ? "["+count+"] " : "") + "kill" + (killOnlyStandingInstructions ? "*" : ""); } + protected abstract boolean isRequeueing(); + public String toString() { return super.toString()+(count==1?"":(isRequeueing()?("("+(count==0?"*":(count+""))+")"):("["+(count==0?"*":(count+""))+"]")))+" "; } + } + public static class UnClog extends Instruction { + public UnClog(Pump pump) { super(pump); } + public String toString() { return super.toString() + "unclog;"; } + } + + public static class Clog extends Instruction { + public Clog(Pump pump) { super(pump); } + public String toString() { return super.toString() + "clog;"; } + } + + public static class Kill extends CountingInstruction { + public Kill(Pump pump, int count) { super(pump, count); } + protected boolean isRequeueing() { return false; } + public String toString() { return super.toString() + "kill;"; } } public static class Executable extends Instruction { - public final Pump pump; public final Destination dest; public final int count; - public final boolean tokenIn; - public final boolean dataIn; - public final boolean latch; - public final boolean dataOutDest; - public final boolean dataOut; - public final boolean tokenOut; - public final boolean requeue; + public final boolean tokenIn; + public final boolean dataIn; + public final boolean latch; + public final boolean dataOutDest; + public final boolean dataOut; + public final boolean tokenOut; + public final boolean requeue; + public final boolean ignoreUntilLast; + + protected boolean isRequeueing() { return requeue; } /** count=0 denotes a standing move */ - public Executable(Pump pump, + public Executable(Pump pump, Destination dest, int count, boolean tokenIn, @@ -42,8 +58,9 @@ public abstract class Instruction { boolean dataOutDest, boolean dataOut, boolean tokenOut, - boolean requeue) { - this.pump = pump; + boolean requeue, + boolean ignoreUntilLast) { + super(pump); this.dest = dest; this.count = count; this.tokenIn = tokenIn; @@ -53,6 +70,7 @@ public abstract class Instruction { this.dataOut = dataOut; this.tokenOut = tokenOut; this.requeue = requeue; + this.ignoreUntilLast = ignoreUntilLast; if (count < 0) throw new RuntimeException("count field of an instruction must be >=0"); } @@ -64,17 +82,12 @@ public abstract class Instruction { public Instruction.Executable decrementCount() { if (count==1) return null; return new Executable(pump, dest, count==0 ? 0 : count-1, - tokenIn, dataIn, latch, dataOutDest, dataOut, tokenOut, requeue); + tokenIn, dataIn, latch, dataOutDest, dataOut, tokenOut, requeue, ignoreUntilLast); } public String toString() { - String ret = pump.toString() + ": "; - if (count==0 || count>1 || requeue) { - ret += requeue ? "(" : "["; - if (count>1) ret += count; - if (count==0) ret += "*"; - ret += requeue ? ")" : "] "; - } + // FIXME + String ret = super.toString(); boolean needcomma = false; if (tokenIn) { ret += (needcomma ? ", " : "") + "wait"; needcomma = true; } if (dataIn && latch) { @@ -98,46 +111,21 @@ public abstract class Instruction { } - public static class LocalLiteral extends Instruction { - public final Pump pump; + public static class LocalLiteral extends CountingInstruction { public final long literal; - public LocalLiteral(Pump pump, long literal) { - this.pump = pump; + public boolean isRequeueing() { return true; } + public LocalLiteral(Pump pump, long literal, int count) { + super(pump, count); this.literal = literal; } } - public static class Literal extends Instruction { - public final Destination dest; - protected Literal(Destination dest) { this.dest = dest; } - - public static class Absolute extends Literal { - public final long value; - public Absolute(Destination dest, long value) { super(dest); this.value = value; } - public String toString() { - return value + ": sendto " + dest; - } - } - - public static class Relative extends Literal { - /** value transmitted will be offset plus the address from which this instruction was loaded */ - public final long offset; - public Relative(Destination dest, long offset) { super(dest); this.offset = offset; } - public String toString() { - String off = ""+offset; - if (offset > 0) off = "+"+off; - return "(@"+offset+"): sendto " + dest; - } - } - } - public static class CodeBagDescriptor extends Instruction { /** address of CBD, relative to address that this instruction was loaded from */ - public final Pump pump; public final long offset; public final long size; public CodeBagDescriptor(Pump pump, long offset, long size) { - this.pump = pump; + super(pump); this.offset = offset; this.size = size; } diff --git a/src/edu/berkeley/fleet/assembler/Parser.java b/src/edu/berkeley/fleet/assembler/Parser.java index a6a55a9..28d3520 100644 --- a/src/edu/berkeley/fleet/assembler/Parser.java +++ b/src/edu/berkeley/fleet/assembler/Parser.java @@ -55,7 +55,7 @@ public class Parser { CodeBag baseCodeBag = new CodeBag(); CodeBag rootCodeBag = new CodeBag(); skip = false; - baseCodeBag.add(new Instruction.Literal.CodeBagDescriptor(null, rootCodeBag.getFakeAddress(), 1)); + baseCodeBag.add(new Instruction.CodeBagDescriptor(null, rootCodeBag.getFakeAddress(), 1)); walk((Tree)parse(r), rootCodeBag); if (fleet instanceof edu.berkeley.fleet.fpga.Fpga) ((edu.berkeley.fleet.fpga.Fpga)fleet).dumpFabric(true); @@ -82,11 +82,11 @@ public class Parser { CodeBag c = codeBags.get(i); dos.flush(); for(Instruction inst : c) { - if (inst instanceof Instruction.Literal.CodeBagDescriptor) { + if (inst instanceof Instruction.CodeBagDescriptor) { dos.flush(); - Instruction.Literal.CodeBagDescriptor old = (Instruction.Literal.CodeBagDescriptor)inst; + Instruction.CodeBagDescriptor old = (Instruction.CodeBagDescriptor)inst; int offset = codeBagMap[(int)old.offset];// - count; - inst = new Instruction.Literal.CodeBagDescriptor(old.pump, + inst = new Instruction.CodeBagDescriptor(old.pump, offset, codeBags.get((int)old.offset).size()); //System.out.println("cbd: " + offset + " " + codeBags.get((int)old.offset).size() + " " + codeBags.get((int)old.offset).name + " " + codeBags.get((int)old.offset)); @@ -272,6 +272,7 @@ public class Parser { boolean tokenOut = false; boolean dataOutDest = false; boolean localLiteral = false; + boolean ignoreUntilLast = false; long literal = 0; Destination dest = null; for(int i=0; i