Line 19... |
Line 19... |
/// List of PLA entries which we want to ignore for various reasons
|
/// List of PLA entries which we want to ignore for various reasons
|
///
|
///
|
public List IgnoredPla = new List();
|
public List IgnoredPla = new List();
|
|
|
///
|
///
|
|
/// List of PLA entries not used by our Timings matrix
|
|
///
|
|
public List NotUsedPla = new List();
|
|
|
|
///
|
/// Returns the total number of PLA table entries
|
/// Returns the total number of PLA table entries
|
///
|
///
|
public int Count()
|
public int Count()
|
{
|
{
|
return pla.Count();
|
return pla.Count();
|
Line 57... |
Line 62... |
}
|
}
|
ClassLog.Log(string.Format("Total {0} PLA lines", pla.Count()));
|
ClassLog.Log(string.Format("Total {0} PLA lines", pla.Count()));
|
|
|
////============================================================
|
////============================================================
|
//// Ignore duplicate PLA entries
|
//// Ignore duplicate PLA entries
|
|
//IgnoredPla.Add(98); // Duplicate of 37
|
|
//IgnoredPla.Add(94); // Duplicate of 12 and 18
|
|
//IgnoredPla.Add(93); // Duplicate of 11 and 19
|
//IgnoredPla.Add(90); // Duplicate of 26
|
//IgnoredPla.Add(90); // Duplicate of 26
|
//IgnoredPla.Add(36); // Duplicate of 8
|
//IgnoredPla.Add(87); // Duplicate of 83
|
//IgnoredPla.Add(71); // Duplicate of 25
|
//IgnoredPla.Add(71); // Duplicate of 25
|
//IgnoredPla.Add(63); // Duplicate of 17
|
//IgnoredPla.Add(63); // Duplicate of 17
|
//IgnoredPla.Add(87); // Duplicate of 83
|
|
//IgnoredPla.Add(60); // Duplicate of 15
|
//IgnoredPla.Add(60); // Duplicate of 15
|
//IgnoredPla.Add(94); // Duplicate of 12 and 18
|
|
//IgnoredPla.Add(18); // Duplicate of 12 and 94
|
|
//IgnoredPla.Add(93); // Duplicate of 11 and 19
|
|
//IgnoredPla.Add(19); // Duplicate of 11 and 93
|
|
//IgnoredPla.Add(98); // Duplicate of 37
|
|
//IgnoredPla.Add(41); // Duplicate of 3
|
//IgnoredPla.Add(41); // Duplicate of 3
|
|
//IgnoredPla.Add(36); // Duplicate of 8
|
//IgnoredPla.Add(32); // Duplicate of 4
|
//IgnoredPla.Add(32); // Duplicate of 4
|
|
//IgnoredPla.Add(19); // Duplicate of 11 and 93
|
|
//IgnoredPla.Add(18); // Duplicate of 12 and 94
|
|
|
////============================================================
|
////============================================================
|
//// Special signals (not instructions)
|
//// Special signals (not instructions)
|
//IgnoredPla.Add(91); // This signal goes along block IN/OUT instructions.
|
//IgnoredPla.Add(91); // This signal goes along block IN/OUT instructions.
|
//IgnoredPla.Add(75); // This signal specifies a decrement operation for PLA 53, 66 and 105. Otherwise, it is an increment.
|
//IgnoredPla.Add(75); // This signal specifies a decrement operation for PLA 53, 66 and 105. Otherwise, it is an increment.
|
Line 81... |
Line 86... |
//IgnoredPla.Add(44); // This signal specifies a regular CB opcode (ignoring IX/IY).
|
//IgnoredPla.Add(44); // This signal specifies a regular CB opcode (ignoring IX/IY).
|
//IgnoredPla.Add(33); // This signal specifies whether the register is being loaded or stored to memory for PLA entry 31.
|
//IgnoredPla.Add(33); // This signal specifies whether the register is being loaded or stored to memory for PLA entry 31.
|
//IgnoredPla.Add(28); // This signal specifies the OUT operation for PLA 37. Otherwise, it is operation.
|
//IgnoredPla.Add(28); // This signal specifies the OUT operation for PLA 37. Otherwise, it is operation.
|
//IgnoredPla.Add(27); // This signal goes along individual IN/OUT instructions in the ED table.
|
//IgnoredPla.Add(27); // This signal goes along individual IN/OUT instructions in the ED table.
|
//IgnoredPla.Add(16); // This signal specifies a PUSH operation for PLA23. Otherwise, it is a POP operation.
|
//IgnoredPla.Add(16); // This signal specifies a PUSH operation for PLA23. Otherwise, it is a POP operation.
|
//IgnoredPla.Add(14); // This signal specifies a decrement operation for PLA 9. Otherwise, it is an increment.
|
|
//IgnoredPla.Add(13); // This signal specifies whether the value is being loaded or stored for PLA entries 8, 30 and 38.
|
//IgnoredPla.Add(13); // This signal specifies whether the value is being loaded or stored for PLA entries 8, 30 and 38.
|
//IgnoredPla.Add(4); // This signal goes along instructions that access I and R register (PLA 57 and 83).
|
|
//IgnoredPla.Add(0); // This signal specifies *not* to repeat block instructions.
|
//IgnoredPla.Add(0); // This signal specifies *not* to repeat block instructions.
|
|
|
////============================================================
|
////============================================================
|
//// Ignore our own reserved entries
|
//// Ignore our own reserved entries
|
//IgnoredPla.Add(106);
|
|
//IgnoredPla.Add(107);
|
//IgnoredPla.Add(107);
|
|
//IgnoredPla.Add(106);
|
|
|
//============================================================
|
//============================================================
|
// Remove op-bits so we the output is more readable
|
// Remove op-bits so we the output is more readable
|
IgnoredPla.Add(99);
|
IgnoredPla.Add(99);
|
IgnoredPla.Add(100);
|
IgnoredPla.Add(100);
|
Line 111... |
Line 114... |
IgnoredPla.Add(79);
|
IgnoredPla.Add(79);
|
IgnoredPla.Add(78);
|
IgnoredPla.Add(78);
|
IgnoredPla.Add(76);
|
IgnoredPla.Add(76);
|
|
|
//============================================================
|
//============================================================
|
|
// Signals not used in the Timings spreadsheet. For those, PLA table entries are not generated.
|
|
// This list is used only when generating the PLA table.
|
|
NotUsedPla.Add(67); // This signal defines a specific in(), but we use in/out pla[27] + pla[34]
|
|
NotUsedPla.Add(62); // This signal is issued for all CB opcodes
|
|
NotUsedPla.Add(54); // This signal specifies every CB with IX/IY
|
|
NotUsedPla.Add(22); // This signal specifies CB prefix w/o IX/IY
|
|
NotUsedPla.Add(14); // This signal specifies a decrement operation for PLA 9. Otherwise, it is an increment.
|
|
NotUsedPla.Add(4); // This signal goes along instructions that access I and R register (PLA 57 and 83).
|
|
|
|
//============================================================
|
// Mark all PLA entries we decided to ignore
|
// Mark all PLA entries we decided to ignore
|
foreach (var p in pla)
|
foreach (var p in pla)
|
{
|
{
|
if (IgnoredPla.Contains(p.N))
|
if (IgnoredPla.Contains(p.N))
|
p.Ignored = true;
|
p.Ignored = true;
|
Line 296... |
Line 309... |
string max = (pla.Count() - 1).ToString();
|
string max = (pla.Count() - 1).ToString();
|
string module = "";
|
string module = "";
|
module += @"//=====================================================================================" + Environment.NewLine;
|
module += @"//=====================================================================================" + Environment.NewLine;
|
module += @"// This file is automatically generated by the z80_pla_checker tool. Do not edit! " + Environment.NewLine;
|
module += @"// This file is automatically generated by the z80_pla_checker tool. Do not edit! " + Environment.NewLine;
|
module += @"//=====================================================================================" + Environment.NewLine;
|
module += @"//=====================================================================================" + Environment.NewLine;
|
module += @"module pla_decode (opcode, prefix, pla);" + Environment.NewLine;
|
module += @"module pla_decode" + Environment.NewLine;
|
|
module += @"(" + Environment.NewLine;
|
|
module += @" input wire [6:0] prefix," + Environment.NewLine;
|
|
module += @" input wire [7:0] opcode," + Environment.NewLine;
|
|
module += @" output wire [" + max + ":0] pla" + Environment.NewLine;
|
|
module += @");" + Environment.NewLine;
|
module += @"" + Environment.NewLine;
|
module += @"" + Environment.NewLine;
|
module += @"input wire [6:0] prefix;" + Environment.NewLine;
|
|
module += @"input wire [7:0] opcode;" + Environment.NewLine;
|
|
module += @"output reg [" + max + ":0] pla;" + Environment.NewLine;
|
|
module += @"" + Environment.NewLine;
|
|
module += @"always_comb" + Environment.NewLine;
|
|
module += @"begin" + Environment.NewLine;
|
|
|
|
foreach (var p in pla)
|
foreach (var p in pla)
|
{
|
{
|
if (p.IsDuplicate())
|
if (p.IsDuplicate() || NotUsedPla.Contains(p.N))
|
continue;
|
continue;
|
|
|
String bitstream = p.GetBitstream();
|
String bitstream = p.GetBitstream();
|
module += string.Format(@" if ({{prefix[6:0], opcode[7:0]}} ==? 15'b{0}) pla[{1,3}]=1'b1; else pla[{1,3}]=1'b0; // {2}",
|
module += string.Format(@"assign pla[{0,3}] = (({{prefix[6:0], opcode[7:0]}} & 15'b{1}) == 15'b{2}) ? 1'b1 : 1'b0; // {3}",
|
bitstream, p.N, p.Comment) + Environment.NewLine;
|
p.N,
|
|
bitstream.Replace('0', '1').Replace('X', '0'), // Create "AND" mask
|
|
bitstream.Replace('X', '0'), // Create a value to compare to
|
|
p.Comment) + Environment.NewLine;
|
|
}
|
|
|
|
// List all PLA entries that are not used
|
|
module += @"" + Environment.NewLine;
|
|
module += @"// Entries not used by our timing matrix" + Environment.NewLine;
|
|
foreach (var n in NotUsedPla)
|
|
{
|
|
module += string.Format(@"assign pla[{0,3}] = 1'b0; // {1}", n, pla[n].Comment) + Environment.NewLine;
|
}
|
}
|
|
|
// Dump all PLA entries that are ignored
|
// List all PLA entries that are ignored
|
module += @"" + Environment.NewLine;
|
module += @"" + Environment.NewLine;
|
module += @" // Duplicate or ignored entries" + Environment.NewLine;
|
module += @"// Duplicate entries" + Environment.NewLine;
|
foreach (var p in pla)
|
foreach (var p in pla)
|
{
|
{
|
if (p.IsDuplicate())
|
if (p.IsDuplicate())
|
module += string.Format(@" pla[{0,3}]=1'b0; // {1}", p.N, p.Comment) + Environment.NewLine;
|
module += string.Format(@"assign pla[{0,3}] = 1'b0; // {1}", p.N, p.Comment) + Environment.NewLine;
|
}
|
}
|
|
|
module += @"end" + Environment.NewLine;
|
|
module += @"" + Environment.NewLine;
|
module += @"" + Environment.NewLine;
|
module += @"endmodule" + Environment.NewLine;
|
module += @"endmodule" + Environment.NewLine;
|
|
|
ClassLog.Log(module);
|
ClassLog.Log(module);
|
}
|
}
|